﻿using System;

namespace Bilibili.Model.Search
{
    public sealed class SearchTopicItem
    {
        public string arcurl { get; set; }
        private string _title;
        public string title
        {
            get => _title;
            set => _title = Uri.UnescapeDataString(value.Replace("<em class=\"keyword\">", string.Empty).Replace("</em>", string.Empty));
        }
        private string _description;
        public string description
        {
            get { return _description; }
            set
            {
                _description = value.Replace("<em class=\"keyword\">", "").Replace("</em>", "");
            }
        }
        public long pubdate { get; set; }
        public string publicDate
        {
            get
            {
                var ts = pubdate.ToString();
                if (ts.Length == 10)
                    ts += "0000000";
                DateTime dtStart = new DateTime(1970, 1, 1, 0, 0, 0);
                TimeSpan toNow = new TimeSpan(long.Parse(ts));
                DateTime dt = dtStart.Add(toNow).ToLocalTime();
                return dt.ToString("yyyy-MM-dd HH:mm:ss");
            }
        }
        private string _pic;
        public string cover
        {
            get { return _pic; }
            set { _pic = "https:" + value; }
        }
    }
}